package com.guigu.tms.base.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.tms.base.service.IPdTruckService;
import com.guigu.tms.commons.entity.base.PdTruck;
import com.guigu.tms.commons.entity.base.VehicleManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 车辆信息表 前端控制器
 * </p>
 *
 * @author wj
 * @since 2022-09-26
 */
@RestController
@RequestMapping("/pdTruck")
public class PdTruckController {

    @Autowired
    IPdTruckService pdTruckService;

    /**
     * 查询全部车辆信息
     *
     * @return
     */
    @GetMapping("/findAllPdTruck")
    public List<PdTruck> findAllPdTruck() {
        return pdTruckService.findAllPdTruck();
    }

    @PostMapping("/findTruckList")
    public PageInfo<VehicleManagement> findTruckList(@RequestBody Map<String, String> map) {
        PageInfo<VehicleManagement> truckList = pdTruckService.findTruckList(map);
        return truckList;
    }

    @PostMapping("/AddPdTruck")
    public int AddPdTruck(@RequestBody VehicleManagement pdTruck) {
        return pdTruckService.AddPdTruck(pdTruck);
    }

    @DeleteMapping("/DeleteTruckByid")
    public int DeleteTruckByid(@RequestParam Integer truckId){
        return pdTruckService.DeleteTruckByid(truckId);
    }

    @PutMapping("/SaveTruck")
    public int SaveTruck(@RequestBody VehicleManagement vehicleManagement){
        System.out.println("对象0------------------"+vehicleManagement);
        return pdTruckService.SaveTruck(vehicleManagement);
    }

}
